<template>
  <el-dialog :visible.sync="value" :before-close="cancel">
    <template slot="title">人工回收</template>
    <el-form :model="form" ref="recoverSetForm">
      <el-form-item>
        <el-col>
          <span class="detail">{{form.message}}</span>
        </el-col>
        <el-col>
          <div class="detail">
            <el-button type="primary" @click="doSave({action: 'saveForm'})" :disabled="isDisabled" :loading="loading">确定回收
            </el-button>
            <el-button @click="cancel">取 消</el-button>
          </div>
        </el-col>
      </el-form-item>
    </el-form>
    <div style="font-size:12px;">
      注1：已回收的提现单“分单给 / 分单时间”显示为空</br>
      注2：提现单状态为处理中时候，则不可进行回收</br>
      注3：已回收的提现单，则不可重复回收
    </div>
  </el-dialog>
</template>

<script>

  import {form} from '@/build'
  import {batchRecoverCheck,batchRecoverInsure} from '@/services/api/withdraw';
  export default {
    name: "batch-recover-dialog",
    mixins: [form],
    props: ['value','rowData'],
    data() {
      return {
      isDisabled:'',
        form:{
          message:''
        },
      }
    },
    mounted() {
      this.bindGet(batchRecoverCheck, 'form',{
        action: 'getGrid',
        beforeSend:()=>{
          return {orderIds : this.rowData.idsArr.join(',')}
        },
        format:(data)=>{
          console.log(data.onSubmit)
          this.isDisabled = data.onSubmit==true?false:true
          return {
            message:data.message,
          }
        }
      });
        this.doGet({action:'getGrid'})

      this.bindSave(batchRecoverInsure, 'saveForm', 'form', {
         beforeSend:()=>{
          return {orderIds : this.rowData.idsArr.join(',')}
        },
        afterSuccess:(data)=>{
          if(data.length>0){
             this.$alert(data[1], '回收结果', {
              confirmButtonText: '确定',
            });
          }
          this.$emit('input', false);
          this.$parent.gridSearch();
        }
      });
    },
    methods: {
      cancel() {
        this.$emit('input', false);
      },
      formatArr(arr){
        return arr.map(item => {
          return {
            value:item.id,
            title:item.userName,
          }
        })
      }
    },

  }
</script>

<style lang="scss" scoped>
  .user{
    color: red;
    display: inline-block;
    min-width: 60px;
    text-align: center;
    text-decoration: underline;
  }
  .detail{
    text-align: center;
    margin-top: 30px;
    font-size: 16px;
  }
</style>
